<?php

namespace app\adm\controller;

use app\base\BaseController;

/**
 * 部门
 */
class Department extends BaseController
{

    /**
     * 获取部门 get_department
     * @return mixed
     */
    public function list_all()
    {

        $department = get_department();
        return to_assign(0, '', $department);
    }


    /**
     * 获取部门树形节点列表 get_department_tree
     * @return \think\response\Json
     */
    public function list_tree()
    {
        $department = get_department();
        $list = get_tree($department, 0, 2);
        $data['trees'] = $list;
        return json($data);
    }

    /**
     * 获取部门树形节点列表2 get_department_select
     * @return mixed
     */
    public function list_tree2()
    {
        $keyword = get_params('keyword');
        $selected = [];
        if(!empty($keyword)){
            $selected = explode(",",$keyword);
        }
        $department = get_department();
        $list = get_select_tree($department, 0,0,$selected);
        return to_assign(0, '',$list);
    }
}